<template>
	<view class="container">
		<view class="tab flex-col-between">
			<text v-for="(item,index) in tab" :style="{color:current== index?'#3B54DA':'#5B5D65'}"
				@click="tabChage(index)">{{item.name}}</text>
		</view>
		<scroll-view class="scroll" scroll-y @scrolltolower="loadMore">
			<view class="list">
				<view class="list-item" v-for="(item,index) in list" :key="index" @click="toDetail(item)">
					<image :src="item.relevance.picture" mode=""></image>
					<text class="ellipsis">{{item.relevance.title}}</text>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		props:{
			tab:{
				type:Array,
				default:()=>{}
			},
			current:{
				type:Number,
				default:0
			},
			list:{
				type:Array,
				default:()=>{}
			}
		},
		data() {
			return {
			};
		},
		onReachBottom(){
			console.log('onReachBottom')
		},
		methods:{
			tabChage(i) {
				this.$emit("currentTab",i)
			},
			toDetail(info){
				this.$emit('toDetail',info)
			},
			loadMore() {
				this.$emit("loadMore")
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		height: 100%;
		display: flex;
		flex-direction: column;
	}
	.tab {
		height: 98rpx;
		padding: 40rpx 30rpx 30rpx;
		border-bottom: 2rpx solid #EFEFEF;

		text {
			font-size: 28rpx;
			font-weight: Regular;
		}
	}
	.scroll {
		flex: 1;
		height: 100%;
	}
	.list {
		padding: 30rpx;
		padding-bottom: 160rpx;
		display: grid;
		grid-template-columns: 1fr 1fr;
		grid-gap: 30rpx;
		.list-item {
			width: 330rpx;
			height: 314rpx;
			border-radius: 20rpx;
			box-shadow: 0 0 15rpx rgba(0, 0, 0, 0.5);
			flex: 1;
			image {
				width: 100%;
				height: 246rpx;
				border-radius: 20rpx;
			}
	
			text {
				display: block;
				margin: 0 auto;
				width: 80%;
				height: 68rpx;
				line-height: 68rpx;
				font-size: 28rpx;
				font-weight: Regular;
				text-align: center;
			}
		}
	}
</style>